home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000127_icon-group-sender _Mon Dec 1 09:24:39 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id JAA06519
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 1 Dec 1997 09:24:38 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA00709; Mon, 1 Dec 1997 09:24:37 -0700
Message-Id: <347B8113.C76C7986@ix.netcom.com>
Date: Tue, 25 Nov 1997 20:53:23 -0500
From: Phillip Lee Thomas <teruthom@ix.netcom.com>
Reply-To: thomaspl@acm.org
X-Mailer: Mozilla 4.03 [en] (Win95; U)
Mime-Version: 1.0
To: Mike D Cross <crossmd@mh.uk.sbphrd.com>
Cc: icon-group@optima.CS.Arizona.EDU
Subject: Re: Question - How to extract data from a formatted line.
References: <199711221443.OAA03592@heu534.ha.uk.sbphrd.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Mike,
I'm not literate in Perl -- your own example might be a fair reason of why I've
avoided
such literacy.
Here's a truncated program that 1) sets up a list, 2) identifies a field
terminator character
sequence, 3) pulls out the strings upto the terminators, 4) places them in a
list, and 5) prints them out.
In any real situation, you would read in the data ("while line := read() do
..."), and determine
whether you need to store the parsed elements for further processing, launder
them further, etc.
In the present example, if your string is not terminated by the field terminator,
then you
need one further put(mylist, tab(0)) after the while loop.
-- Phillip Thomas
procedure main()
mylist := []
terminator := "xxx"
line := "this isxxxa linexxxof formatted dataxxx"
line ? {
while put(mylist, tab(find(terminator))) do # grab the data
move(*terminator) # skip length of
terminator
}
while write(pop(mylist))
end
Mike D Cross wrote:
> Hi,
>
> I've been given some Perl programs which extract data from lines
> of text, each line being of a set format. In perl you do:
>
> @dumpline = /^RLOGNAME=\"(.*)\" UID=\"(.*)\" GID=\"(.*)\" PROFILE=\"(.*)\"